package persistencia;

import java.sql.Connection;
import java.sql.DriverManager;

public class Persistencia_Conexion {

    private static Connection connection;

    public static Connection getConnection() {
        //Si la conexion no estaba creada la crea, sino simplemente la devuelve
        String ruta = "jdbc:mysql://192.168.1.33/game-book";
        //String ruta = "jdbc:mysql://192.168.0.192/game-book";
        String usuario = "gamebook";
        String password = "gamebook";

        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            connection = DriverManager.getConnection(ruta, usuario, password);
        } catch (ClassNotFoundException cnf) {
            System.out.println(cnf.getMessage());
        } catch (InstantiationException ie) {
            System.out.println(ie.getMessage());
        } catch (IllegalAccessException iae) {
            System.out.println(iae.getMessage());
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

        return connection;
    }
}
